<template>
    <!-- 食物显示的方块 -->
    <div class="content_item">
        <!-- 左半部分 -->
        <div class="left">
            <van-checkbox v-if="showCheck"  :name="item.id" checked-color="#ffc400"></van-checkbox>
            <!-- 食物图片 -->
            <img :src="item.pic" />
            <!-- 文字部分 -->
            <div class="text">
                <!-- 食物名称 -->
                <div class="title">{{ item.title }}</div>
                <!-- 加号图标 -->
                <!-- 绑定传入的事件，使用参数是当前数据的id -->

                <van-icon name="add-o" v-if="item.add && showAdd" class="van-icon" @click="addClick(item.id)"></van-icon>
                <van-stepper v-model="item.num" v-else :min="1" :name="item.id" @change = "onChange" />
                <!-- <van-slider v-model="item.num" v-else :min="1" :name="item.id"></van-slider> -->
            </div>
        </div>
        <!-- 右半部分 价格显示 -->
        <div class="price">￥ {{ item.price }}</div>
    </div>
</template>
<script>
import { defineComponent } from 'vue';
export default defineComponent({
    name: 'App',
    // 接收数据，接收事件
    props: ['item', "showAdd","addClick","onChange","showCheck"]

})
</script>
<style lang="less" scoped>
.content_item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;

    .price {
        font-size: 16px;
        font-weight: 600;
    }

    .left {
        
        display: flex;
        align-items: center;
        flex: 1;

        img {
            margin-left: 10px;
            width: 60px;
            height: 60px;
            margin-right: 10px;
            border-radius: 10px;
        }

        .text {
            display: flex;
            flex-flow: column;
            justify-content: space-between;
            height: 100%;
            position: relative;
            flex: 1;

            .title {
                font-size: 10px;
                font-weight: 700;
            }

            .van-icon {
                color: red;
                font-size: 20px;
                position: absolute;
                right: 4px;
                bottom: 4px;
            }
        }

    }

}
</style>